# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=lib2geom
pkgver=1.3
pkgrel=3
pkgdesc="Easy to use 2D geometry library for c++"
url="https://gitlab.com/inkscape/lib2geom"
arch="all"
license="MPL-1.1 OR LGPL-2.1-only"
depends_dev="
	boost-dev
	cairo-dev
	double-conversion-dev
	gsl-dev
	"
makedepends="
	$depends_dev
	cmake
	cython
	gtk+3.0-dev
	ragel
	samurai
	"
checkdepends="gtest-dev"
subpackages="$pkgname-dev"
source="https://gitlab.com/inkscape/lib2geom/-/archive/$pkgver/lib2geom-$pkgver.tar.bz2"

# inkscape used to install the same shared library
replaces="inkscape"

# probably fpmath=sse related failures
case "$CARCH" in
x86) options="$options !check" ;;
esac

build() {
	CFLAGS="$CFLAGS -O2 -DNDEBUG -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-D2GEOM_BUILD_SHARED=ON \
		-D2GEOM_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j${JOBS:-2} \
		-E '(circle-test|bezier-test|elliptical-arc-test)'
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2e24ec1496ad7cafcd457f8a7d201ddad0b92915889bef3015cec5238de8393bf7ce7f47799f4c72c9253ed50fdbdcf2f810f76fe4f62bf916ef3debe4c32cb1  lib2geom-1.3.tar.bz2
"
